package com.llh.spring.aop.helloworld;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

import org.junit.Test;
//dsdd
public class ReviewTest {
		
	@Test
	public void getConnection3() throws Exception{
		/**
		 * 
		 * 0. 读取jdbc.properties
		 * 1. 属性文件对应Java中的Properties类
		 * 2. 可以使用类加载器加载bin目录（类路径下）的文件
		 */
		Properties properties = new Properties();
		//类加载器获取配置文件成为输入流
		InputStream is = ReviewTest.class.getClassLoader().getResourceAsStream("oracle-db.properties");
		properties.load(is);
		String user = properties.getProperty("user");
		String password =properties.getProperty("password");
		String jdbcUrl =properties.getProperty("jdbcUrl");
		//加载驱动，driverClass是MySQL数据库驱动的全类名，由数据库厂家提供
		String driverClass = properties.getProperty("driverClass");
		Class.forName(driverClass);
		Connection conn = (Connection) DriverManager.getConnection(jdbcUrl, user, password);
		System.out.println(conn);
	}//22

}
